package laps.dataaccess.mysql;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import laps.dataaccess.CompensationClaimDAO;
import laps.model.CompensationClaim;
import laps.model.Employee;

public class CompensationClaimDAOImpl implements CompensationClaimDAO {

	private Connection connection;

	public CompensationClaimDAOImpl(Connection connection) {
		super();
		this.connection = connection;
	}

	@Override
	public ArrayList<CompensationClaim> getClaims(Employee employee,
			String role, String status) {
		ArrayList<CompensationClaim> claimList = new ArrayList<CompensationClaim>();
		
		
		return claimList;
	}

	@Override
	public CompensationClaim getClaimByID(int claimID) {
		CompensationClaim claim = new CompensationClaim();
		
		String sql = "select * from laps_db.compensation_claim_record where compensation_claim_id=" + claimID + ";";
		
		Statement statement = null;
		ResultSet resultSet = null;
		
		try {
			statement = connection.createStatement();
			resultSet = statement.executeQuery(sql);
			
			resultSet.next();
			
			claim.setCompensation_claim_id(resultSet.getInt("compensation_claim_id"));
			claim.setApplied_by(resultSet.getInt("applied_by"));
			claim.setApproved_by(resultSet.getInt("approved_by"));
			claim.setApplication_date(resultSet.getDate("application_date"));
			claim.setDate_of_overtime(resultSet.getDate("date_of_overtime"));
			claim.setRemarks(resultSet.getString("remarks"));
			claim.setSign_int_time(resultSet.getInt("sign_in_time"));
			claim.setSign_out_time(resultSet.getInt("sign_out_time"));
			claim.setStatus(resultSet.getString("status"));
			
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		return claim;
	}

	@Override
	public CompensationClaim getNewClaim() {
		return new CompensationClaim();
	}

	@Override
	public int submitClaim(CompensationClaim claim) {
		int claimID = 0;
		
		String sql = "insert into laps_db.compensation_claim ";
		
		return claimID;
	}

	@Override
	public boolean updateClaim(CompensationClaim claim) {
		boolean success = false;
		
		String sql = "update laps_db.compensation_claim set = ";
		
		
		
		
		
		return success;
	}
	
	
}
